var arr = ['./image/1.jpg','./image/2.jpg',"./image/3.jpg","./image/4.jpg","./image/5.jpg","./image/6.jpg"]
    var index = 0
    // console.log(arr[2])
    $(function () {
        var str = ""
        for (var i = 0; i < arr.length; i++) {
            str += `<li></li>`
        }
        $("ul").html(str)
        $("li").click(function (v, index) {
            index = $(this).index()
            $("#tp").prop("src", arr[index])
            qhbj(index)
        })
        $("li:first").attr("class", "bj")
        setInterval(function () {
            //console.log($("#tp"))
            $("#tp").prop("src", arr[index])
            qhbj(index)
            // index++
            // if (index > 5) {
            //     index = 0
            // }
              index=index==5?0:++index
        }, 2000)
        $("#left").click(function(){
            index=index==0?5:--index
            $("#tp").prop("src", arr[index])
            qhbj(index)
        })
        $("#right").click(function(){
            index=index==5?0:++index
            $("#tp").prop("src", arr[index])
            qhbj(index)
        })

    })
    function qhbj(index) {
        $("li").attr("class", "")
        $("li:eq(" + index + ")").attr("class", "bj")
    }